Skip to content

Import a picture by its address - #79

Merged
davior merged 1 commit into
mainfrom
claude/peaceful-feynman-v19ec2
Nov 20, 2026
Merged

davior merged 1 commit into
mainfrom
claude/peaceful-feynman-v19ec2

Conversation

@davior

@davior davior commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Summary

The GAM part of letting Video Creator find pictures on the web for backgrounds and overlays. GVC finds them through Gecko Suite's image search (davior/gecko-suite#25), the person picks one, and GVC files it here with this endpoint.

POST /api/assets/import-image {image_url, page_url?, title?, description?, tags?} returns 201 with the new asset, or 200 with the copy already held.

  • Inline, not queued. The caller is waiting to place the picture, and it is one bounded download (40 MB) plus a thumbnail, through the upload's own ingest_file.
  • Safety: ingest/web.py's rules (an SSRF check on every redirect hop, uncompressed bodies only, capped while arriving). download_image sits beside download_audio, which now share one streaming download.
  • Type: the server's Content-Type first, the path's extension as the fallback. A page answering for a picture (a hotlink guard) is refused, and SVG is never taken from the web.
  • Duplicates: by address before downloading, then by checksum. The existing asset is returned untouched.
  • Credit: source_url (the page when known), retrieved_at and the search's description, stamped embedded. Licence and creator stay empty, since no search backend knows them.
  • docs/image-import.md records the decisions. page_import._same_file became the public same_file, used by both.

Test plan

  • cd backend && pytest -q: 1631 passed. tests/test_image_import.py covers import and credit, both duplicate paths, type from the server, a page refused, SVG refused, an inward address and an inward redirect, the size cap, a bad page address, and signed-out.
  • No frontend change, so the frontend suite wasn't run.

Deployment

Nothing beyond the standard redeploy (backend only, no migration, no new configuration).


Generated by Claude Code

POST /api/assets/import-image downloads one picture and catalogues it
through the upload's own ingest, for Video Creator's image search. Inline
rather than queued: the caller is waiting to place it, and it is one
bounded download. The SSRF check runs on every hop; the server's type names
the file, a page answering for a picture is refused, SVG is never taken from
the web. A repeat is caught by address, then by checksum, and returns the
existing asset. The page is recorded as the source, with retrieved_at and
the search's description, stamped embedded; licence and creator stay empty
because no search knows them.

download_image sits beside download_audio in ingest/web.py, which now share
one streaming download.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1geD3rf5gNTeFwCtstRx7
@davior
davior marked this pull request as ready for review November 20, 2026 22:43
@davior
davior merged commit a7f9c6f into main Nov 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants